// @ts-ignore
/* eslint-disable */

import { request, type RequestOptions } from '@/utils/request';
import type { MaterialCategorySearch, MaterialCategorySearchOut, MaterialCategoryOut, MaterialCategoryInput } from '../types/material';

/**
 * 获取物料分类分页列表
 * @param input 搜索参数
 * @returns 物料分类列表
 */
export async function list(input: MaterialCategorySearch, options?: RequestOptions) {
    return request<MaterialCategorySearchOut>(`material-category/list`, {
        method: 'POST',
        data: input,
        ...(options || {}),
    });
}

/**
 * 获取物料分类树形结构
 * @param input 搜索参数
 * @returns 物料分类树
 */
export async function tree(input?: MaterialCategorySearch, options?: RequestOptions) {
    return request<MaterialCategoryOut[]>(`material-category/tree`, {
        method: 'POST',
        data: input || {},
        ...(options || {}),
    });
}

/**
 * 获取所有物料分类
 * @returns 所有物料分类
 */
export async function all(options?: RequestOptions) {
    return request<MaterialCategoryOut[]>(`material-category/all`, {
        method: 'GET',
        ...(options || {}),
    });
}

/**
 * 获取单个物料分类
 * @param id 物料分类ID
 * @returns 物料分类详情
 */
export async function get(id: string, options?: RequestOptions) {
    return request<MaterialCategoryOut>(`material-category/${id}`, {
        method: 'GET',
        ...(options || {}),
    });
}

/**
 * 创建物料分类
 * @param input 物料分类数据
 * @returns 操作结果
 */
export async function createCategory(input: MaterialCategoryInput, options?: RequestOptions) {
    return request<string>(`material-category/edit`, {
        method: 'POST',
        data: input,
        ...(options || {}),
    });
}

/**
 * 编辑物料分类
 * @param input 物料分类数据
 * @returns 操作结果
 */
export async function editCategory(input: MaterialCategoryInput & { id?: string }, options?: RequestOptions) {
    return request<string>(`material-category/edit`, {
        method: 'POST',
        data: input,
        ...(options || {}),
    });
}

/**
 * 删除物料分类
 * @param id 物料分类ID
 * @returns 操作结果
 */
export async function deleteCategory(id: string, options?: RequestOptions) {
    return request<string>(`material-category/${id}/logic-delete`, {
        method: 'POST',
        ...(options || {}),
    });
}

/**
 * 获取物料分类（别名，兼容老接口）
 * @param input 搜索参数
 * @returns 物料分类树
 */
export async function categories(input?: MaterialCategorySearch, options?: RequestOptions) {
    return request<MaterialCategoryOut[]>(`material-category/tree`, {
        method: 'POST',
        data: input || {},
        ...(options || {}),
    });
}

/**
 * 创建/编辑物料分类
 * @param input 物料分类数据
 * @returns 操作结果
 */
export async function edit(input: MaterialCategoryInput & { id?: string }, options?: RequestOptions) {
    return request<string>(`material-category/edit`, {
        method: 'POST',
        data: input,
        ...(options || {}),
    });
}

/**
 * 逻辑删除物料分类
 * @param id 物料分类ID
 * @returns 操作结果
 */
export async function logicDelete(id: string, options?: RequestOptions) {
    return request<string>(`material-category/${id}/logic-delete`, {
        method: 'POST',
        ...(options || {}),
    });
}

/**
 * 启用物料分类
 * @param id 物料分类ID
 * @returns 操作结果
 */
export async function enable(id: string, options?: RequestOptions) {
    return request<string>(`material-category/${id}/enable`, {
        method: 'POST',
        ...(options || {}),
    });
}

/**
 * 禁用物料分类
 * @param id 物料分类ID
 * @returns 操作结果
 */
export async function disable(id: string, options?: RequestOptions) {
    return request<string>(`material-category/${id}/disable`, {
        method: 'POST',
        ...(options || {}),
    });
} 